package com.atguigu.yygh.order.controller;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.order.service.WeiPatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user/order/weixin")
public class WeiPayController {

    @Autowired
    private WeiPatService weiPatService;

    @GetMapping("/status/{orderId}")
    public R getPayStatus(@PathVariable Long orderId){
        Map<String,String> map= weiPatService.queryPayStatus(orderId);
        if (map == null){
            return R.error().Message("查询失败");
        }

        return R.ok();
    }


    @GetMapping("/{orderId}")
    public R createNative(@PathVariable Long orderId){
        String url = weiPatService.createNative(orderId);
        return R.ok().data("url",url);
    }
}
